home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / jumpingrope.swf / scripts / frame_25 / DoAction.as
Text File  |  2007-10-01  |  11KB  |  420 lines

  1. function upUserF(upN)
  2. {
  3.    _root.jumpSound.start();
  4.    _root["user" + upN + "Down"] = "yes";
  5. }
  6. function downUserF(downN)
  7. {
  8.    _root.downSound.start();
  9.    _root["user" + downN + "Down"] = "no";
  10. }
  11. function startGameF()
  12. {
  13.    dep = 10;
  14.    stageCount = maxCount;
  15.    stageMaxN = stageCount;
  16.    userN = stageN;
  17.    nowTime = maxTime - (userN - 1) * danTime;
  18.    jumpingVis = "no";
  19.    var _loc2_ = 1;
  20.    while(_loc2_ <= maxUser)
  21.    {
  22.       _root["user" + _loc2_ + "Down"] = "no";
  23.       _root["user" + _loc2_ + "Up"] = "up";
  24.       _loc2_ = _loc2_ + 1;
  25.    }
  26.    attachMovie("ropeRun1","ropeRun1_mc",1);
  27.    _root.ropeRun1_mc._x = 200;
  28.    _root.ropeRun1_mc._y = 57;
  29.    attachMovie("ropeRun2","ropeRun2_mc",20);
  30.    _root.ropeRun2_mc._x = 200;
  31.    _root.ropeRun2_mc._y = 257;
  32.    attachMovie("line","line_mc",2);
  33.    _root.line_mc._x = 200;
  34.    _root.line_mc._y = 150;
  35.    attachMovie("user" + stageN + "_mc","userMc_" + stageN,dep++);
  36.    _root["userMc_" + stageN]._x = 150;
  37.    _root["userMc_" + stageN]._y = 90;
  38.    attachMovie("start","start_mc",1000);
  39.    _root.start_mc._x = 200;
  40.    _root.start_mc._y = 150;
  41.    ranRopeF();
  42.    _root.startSound.start();
  43.    start_mc.gotoAndPlay("startF");
  44. }
  45. function reStart()
  46. {
  47.    if(stageN >= 4)
  48.    {
  49.       userN = 4;
  50.    }
  51.    else
  52.    {
  53.       userN = stageN;
  54.    }
  55.    times_mc.gotoAndStop(1);
  56.    ui_mc.gotoAndStop(1);
  57.    stageCount = maxCount + stageKindN * (userN - 1);
  58.    stageMaxN = stageCount;
  59.    jumpingVis = "no";
  60.    var _loc2_ = 1;
  61.    while(_loc2_ <= maxUser)
  62.    {
  63.       _root["user" + _loc2_ + "Down"] = "no";
  64.       _root["user" + _loc2_ + "Up"] = "up";
  65.       _loc2_ = _loc2_ + 1;
  66.    }
  67.    dep = 10;
  68.    reUserMakeF();
  69.    if(stageN == 3)
  70.    {
  71.       ropeMaxN = 20;
  72.       ropeDn = 3;
  73.    }
  74.    ranRopeF();
  75.    _root.startSound.start();
  76.    start_mc.gotoAndPlay("startF");
  77. }
  78. function ranRopeF()
  79. {
  80.    randomN = random(3) + 1;
  81.    ranRopeN1 = stageMaxN / 5 * randomN;
  82. }
  83. function startRopeF()
  84. {
  85.    nowF = "main";
  86.    if(soundon == "yes")
  87.    {
  88.       _root.backSound = new Sound(this);
  89.       _root.backSound.attachSound("backSoundM");
  90.    }
  91.    _root.backSound.start(0,999);
  92.    Key.addListener(keyListener);
  93.    ropeRun1_mc.gotoAndStop("ropeF");
  94.    ropeRun2_mc.gotoAndStop("ropeF");
  95.    line_mc.gotoAndStop("level" + userN);
  96.    if(nowTime == maxTime - (userN - 1) * danTime)
  97.    {
  98.       ui_mc.timer_mc.in_mc._xscale = 100;
  99.       nowTime = maxTime - (userN - 1) * danTime;
  100.       timeDn = 100 / parseInt(nowTime);
  101.    }
  102.    ropeN = 1;
  103.    nowRopeN = ropeMaxN;
  104.    ropeRunInter = setInterval(ropeRunF,nowRopeN);
  105.    timerInter = setInterval(timerF,500);
  106. }
  107. function ropeRunF()
  108. {
  109.    if(stageCount == ranRopeN1)
  110.    {
  111.       nowRopeN = ropeMaxN;
  112.       clearInterval(ropeRunInter);
  113.       ropeRunInter = setInterval(ropeRunF,nowRopeN);
  114.    }
  115.    else
  116.    {
  117.       switch(stageCount)
  118.       {
  119.          case stageMaxN / 5 * 4:
  120.             nowRopeN = ropeMaxN - 1 * ropeDn;
  121.             clearInterval(ropeRunInter);
  122.             ropeRunInter = setInterval(ropeRunF,nowRopeN);
  123.             break;
  124.          case stageMaxN / 5 * 3:
  125.             nowRopeN = ropeMaxN - 2 * ropeDn;
  126.             clearInterval(ropeRunInter);
  127.             ropeRunInter = setInterval(ropeRunF,nowRopeN);
  128.             break;
  129.          case stageMaxN / 5 * 2:
  130.             nowRopeN = ropeMaxN - 3 * ropeDn;
  131.             clearInterval(ropeRunInter);
  132.             ropeRunInter = setInterval(ropeRunF,nowRopeN);
  133.             break;
  134.          case stageMaxN / 5 * 1:
  135.             nowRopeN = ropeMaxN - 4 * ropeDn;
  136.             clearInterval(ropeRunInter);
  137.             ropeRunInter = setInterval(ropeRunF,nowRopeN);
  138.       }
  139.    }
  140.    ropeRun1_mc.in_mc.gotoAndStop(ropeN);
  141.    ropeRun2_mc.in_mc.gotoAndStop(ropeN);
  142.    line_mc.in_mc.gotoAndStop(ropeN);
  143.    if(ropeN == 60)
  144.    {
  145.       ropeN = 1;
  146.    }
  147.    else
  148.    {
  149.       ropeN++;
  150.    }
  151. }
  152. function timerF()
  153. {
  154.    nowTime--;
  155.    if(nowTime == 0)
  156.    {
  157.       clearInterval(timerInter);
  158.       ui_mc.timer_mc.in_mc._xscale = 0;
  159.       clearInterval(timerInter);
  160.       Key.removeListener(keyListener);
  161.       clearInterval(ropeRunInter);
  162.       var _loc2_ = 1;
  163.       while(_loc2_ <= userN)
  164.       {
  165.          _root["userMc_" + _loc2_].gotoAndStop("dist");
  166.          _loc2_ = _loc2_ + 1;
  167.       }
  168.       gaemOverInter = setInterval(gameOverF,20);
  169.    }
  170.    else
  171.    {
  172.       ui_mc.timer_mc.in_mc._xscale = parseInt(nowTime) * timeDn;
  173.    }
  174. }
  175. function reUserMakeF()
  176. {
  177.    attachMovie("ropeRun1","ropeRun1_mc",1);
  178.    _root.ropeRun1_mc._x = 200;
  179.    _root.ropeRun1_mc._y = 57;
  180.    attachMovie("ropeRun2","ropeRun2_mc",20);
  181.    _root.ropeRun2_mc._x = 200;
  182.    _root.ropeRun2_mc._y = 257;
  183.    attachMovie("line","line_mc",2);
  184.    _root.line_mc._x = 200;
  185.    _root.line_mc._y = 150;
  186.    var _loc2_ = 1;
  187.    while(_loc2_ <= userN)
  188.    {
  189.       attachMovie("user" + _loc2_ + "_mc","userMc_" + _loc2_,dep++);
  190.       _loc2_ = _loc2_ + 1;
  191.    }
  192.    userMcWi = parseInt(_root.userMc_1._width) - 15;
  193.    switch(userN)
  194.    {
  195.       case 1:
  196.          _root["userMc_" + userN]._x = 150;
  197.          _root["userMc_" + userN]._y = 90;
  198.          break;
  199.       case 2:
  200.          _root["userMc_" + (userN - 1)]._x = 107.6;
  201.          _root["userMc_" + (userN - 1)]._y = 90;
  202.          _root["userMc_" + userN]._x = 185.4;
  203.          _root["userMc_" + userN]._y = 90;
  204.          break;
  205.       case 3:
  206.          _root["userMc_" + (userN - 2)]._x = 67;
  207.          _root["userMc_" + (userN - 2)]._y = 90;
  208.          _root["userMc_" + (userN - 1)]._x = 144.8;
  209.          _root["userMc_" + (userN - 1)]._y = 90;
  210.          _root["userMc_" + userN]._x = 226.1;
  211.          _root["userMc_" + userN]._y = 83;
  212.          break;
  213.       case 4:
  214.          _root["userMc_" + (userN - 3)]._x = 26.3;
  215.          _root["userMc_" + (userN - 3)]._y = 90;
  216.          _root["userMc_" + (userN - 2)]._x = 104.1;
  217.          _root["userMc_" + (userN - 2)]._y = 90;
  218.          _root["userMc_" + (userN - 1)]._x = 185.3;
  219.          _root["userMc_" + (userN - 1)]._y = 83;
  220.          _root["userMc_" + userN]._x = 266.6;
  221.          _root["userMc_" + userN]._y = 85;
  222.    }
  223. }
  224. function jumpingF(jumpN)
  225. {
  226.    if(jumpN == 1)
  227.    {
  228.       var _loc2_ = 1;
  229.       while(_loc2_ <= userN)
  230.       {
  231.          _root["user" + _loc2_ + "jump"] = "no";
  232.          _loc2_ = _loc2_ + 1;
  233.       }
  234.    }
  235.    _root["jumpingVis" + jumpN] = "yes";
  236. }
  237. function jumpChcekF(chcekN)
  238. {
  239.    jumpChceKV = "yes";
  240.    if(_root["user" + chcekN + "Down"] == "no")
  241.    {
  242.       _root.hitSound.start();
  243.       _root["userMc_" + chcekN].gotoAndStop("hit");
  244.       var _loc2_ = 1;
  245.       while(_loc2_ <= userN)
  246.       {
  247.          _root["user" + _loc2_ + "Down"] = "yes";
  248.          if(_loc2_ != chcekN)
  249.          {
  250.             _root["user" + _loc2_ + "jump"] = "yes";
  251.          }
  252.          _loc2_ = _loc2_ + 1;
  253.       }
  254.       stageEnd();
  255.       stageEndInter = setInterval(failureF,2000);
  256.    }
  257.    else if(chcekN == userN)
  258.    {
  259.       scoreF();
  260.       countF();
  261.    }
  262. }
  263. function stageEnd()
  264. {
  265.    clearInterval(timerInter);
  266.    Key.removeListener(keyListener);
  267.    clearInterval(ropeRunInter);
  268.    var _loc2_ = 1;
  269.    while(_loc2_ <= userN)
  270.    {
  271.       if(_root["user" + _loc2_ + "jump"] == "yes")
  272.       {
  273.          _root["userMc_" + _loc2_].gotoAndStop("dist");
  274.       }
  275.       _loc2_ = _loc2_ + 1;
  276.    }
  277. }
  278. function gameOverF()
  279. {
  280.    nowF = "noting";
  281.    _root.backSound.stop();
  282.    delete _root.backSound;
  283.    clearInterval(gaemOverInter);
  284.    var _loc2_ = 1;
  285.    while(_loc2_ <= stageN)
  286.    {
  287.       _root["userMc_" + _loc2_].removeMovieClip();
  288.       _loc2_ = _loc2_ + 1;
  289.    }
  290.    start_mc.removeMovieClip();
  291.    ropeRun1_mc.removeMovieClip();
  292.    ropeRun2_mc.removeMovieClip();
  293.    times_mc.gotoAndStop("hide");
  294.    line_mc.removeMovieClip();
  295.    _root.gameOverSound.start();
  296.    _root.gotoAndStop("gameOver");
  297. }
  298. function failureF()
  299. {
  300.    nowF = "noting";
  301.    _root.backSound.stop();
  302.    delete _root.backSound;
  303.    clearInterval(stageEndInter);
  304.    var _loc2_ = 1;
  305.    while(_loc2_ <= stageN)
  306.    {
  307.       _root["userMc_" + _loc2_].removeMovieClip();
  308.       _loc2_ = _loc2_ + 1;
  309.    }
  310.    ropeRun1_mc.removeMovieClip();
  311.    ropeRun2_mc.removeMovieClip();
  312.    line_mc.removeMovieClip();
  313.    times_mc.gotoAndStop("hide");
  314.    _root.readySound.start();
  315.    failure_mc.gotoAndPlay(2);
  316. }
  317. function countF()
  318. {
  319.    stageCount--;
  320.    if(0 == stageCount)
  321.    {
  322.       Key.removeListener(keyListener);
  323.       clearInterval(timerInter);
  324.       stageUpInter = setInterval(stageUpF,20);
  325.    }
  326. }
  327. function stageUpF()
  328. {
  329.    clearInterval(stageUpInter);
  330.    Key.removeListener(keyListener);
  331.    clearInterval(ropeRunInter);
  332.    leverClearInter = setInterval(levelClear,20);
  333. }
  334. function levelClear()
  335. {
  336.    clearInterval(leverClearInter);
  337.    times_mc.gotoAndStop("hide");
  338.    var _loc3_ = 1;
  339.    while(_loc3_ <= userN)
  340.    {
  341.       _root["userMc_" + _loc3_].removeMovieClip();
  342.       _loc3_ = _loc3_ + 1;
  343.    }
  344.    ropeRun1_mc.removeMovieClip();
  345.    ropeRun2_mc.removeMovieClip();
  346.    times_mc.gotoAndStop("hide");
  347.    line_mc.removeMovieClip();
  348.    _root.backSound.stop();
  349.    delete _root.backSound;
  350.    nowF = "levelClear";
  351.    if(soundon == "yes")
  352.    {
  353.       levelClearSound = new Sound(this);
  354.       levelClearSound.attachSound("levelClearSoundM");
  355.    }
  356.    _root.levelClearSound.start(0,999);
  357.    levelClear_mc.gotoAndPlay(2);
  358.    temp = parseInt(nowTime) * (parseInt(timebonus) / 2);
  359.    nowTime = maxTime - userN * danTime;
  360. }
  361. function ready()
  362. {
  363.    stageN++;
  364.    nowF = "noting";
  365.    backN = stageN % 3 != 0 ? stageN % 3 : 3;
  366.    _root.back_mc.gotoAndStop(backN);
  367.    ui_mc.gotoAndStop(2);
  368.    _root.levelClearSound.stop();
  369.    delete _root.levelClearSound;
  370.    _root.readySound.start();
  371.    ready_mc.gotoAndPlay(2);
  372.    stageMaxN = maxCount + stageKindN * userN;
  373. }
  374. function scoreF()
  375. {
  376.    game_score += 100;
  377. }
  378. function titleMoveF()
  379. {
  380.    _root.gameOverSound.stop();
  381.    gotoAndStop("wait_start");
  382.    play();
  383. }
  384. nowF = "noting";
  385. _root.titleSound.stop();
  386. delete _root.titleSound;
  387. _root.readySound.start();
  388. maxUser = 4;
  389. maxCount = 15;
  390. maxTime = 280;
  391. danTime = 20;
  392. stageN = 1;
  393. game_score = 0;
  394. timebonus = 200;
  395. maxLineN = 16;
  396. minLineN = 2;
  397. stageKindN = 5;
  398. ropeMaxN = 23;
  399. ropeDn = 3;
  400. var keyListener = new Object();
  401. keyListener.onKeyUp = function()
  402. {
  403.    if(Key.getCode() == 90)
  404.    {
  405.       _root.user1Up = "up";
  406.    }
  407.    if(Key.getCode() == 88)
  408.    {
  409.       _root.user2Up = "up";
  410.    }
  411.    if(Key.getCode() == 67)
  412.    {
  413.       _root.user3Up = "up";
  414.    }
  415.    if(Key.getCode() == 86)
  416.    {
  417.       _root.user4Up = "up";
  418.    }
  419. };
  420.